package com.qmds.common.core.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * --- 代码敲烂 月薪过万 ---
 *
 * @author ShiJiaWei
 * @date 2024/8/12
 * @desc:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {

    private Integer code;
    private String message;
    private T data;

    /**
     * 成功
     */
    public static <T> R<T> ok() {
        return new R<>(20000, "成功！", null);
    }

    public static <T> R<T> ok(T data) {
        return new R<>(20000, "成功！", data);
    }

    public static <T> R<T> ok(String message, T data) {
        return new R<>(20000, message, data);
    }

    /**
     * 失败
     */
    public static <T> R<T> fail() {
        return new R<>(40000, "失败！", null);
    }

    public static <T> R<T> fail(String message) {
        return new R<>(40000, message, null);
    }

    public static <T> R<T> fail(Integer code, String message) {
        return new R<>(code, message, null);
    }

}
